package org.example.thread.thread01;

import lombok.SneakyThrows;

import java.util.concurrent.locks.ReentrantLock;


/**
 * @Auther:Liu
 * @Testname:Demo0403
 * @Date:2025/8/14 11:08
 */
public class Demo0403 {
    @SneakyThrows
    public void a() {
        String name = Thread.currentThread().getName();
        System.out.println(name + "准备去厕所");
        ReentrantLock lock = new ReentrantLock();
        lock.lock();
            System.out.println(name + "给厕所上锁");
            Thread.sleep(3000);
            System.out.println(name + "给厕所解锁");
       lock.unlock();
    }
}
